package com.foxchen.textinputapp.common;

import lombok.*;

@Getter
@Setter
@ToString
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResponseBean<T> {
    private Integer code;

    private T data;

    private String msg;

    public static <T> ResponseBean<T> success(T data){
        ResponseBean<T> responseBean = new ResponseBean<>();
        responseBean.setCode(0);
        responseBean.setData(data);
        return responseBean;
    }

    public static ResponseBean<?> error(String msg){
        ResponseBean<?> responseBean = new ResponseBean<>();
        responseBean.setCode(-1);
        responseBean.setMsg(msg);
        return responseBean;
    }
}
